import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '/app/pages/home/home_page.dart';
import '/app/pages/settings/settings_page.dart';

class AppController extends GetxController {
  // 设定可用的导航列表
  final _initNavData = <BottomNavigationBarItem>[].obs;
  final _initNavPage = <Widget>[].obs;

  var sortList = <int>[].obs;

  var itemNavData = <BottomNavigationBarItem>[].obs;
  var itemNavPage = <Widget>[].obs;
  var currentIndex = 0.obs;

  @override
  void onInit() {
    super.onInit();
    // 初始化导航按钮
    _initNavData.addAll([
      const BottomNavigationBarItem(
        icon: Icon(Icons.home),
        label: 'Home',
      ),
      const BottomNavigationBarItem(
        icon: Icon(Icons.home),
        label: 'Home2',
      ),
      const BottomNavigationBarItem(
        icon: Icon(Icons.home),
        label: 'Home3',
      ),
      const BottomNavigationBarItem(
        icon: Icon(Icons.settings),
        label: 'Settings',
      ),
    ]);
    _initNavPage.addAll([
      HomePage(),
      HomePage(),
      HomePage(),
      HomePage(),
      SettingsPage(),
    ]);

    itemNavData.addAll(_initNavData);
    itemNavPage.addAll(_initNavPage);
    currentIndex.value = 0;
  }

  FunSort() {}

  changeNavIndex(int index) {
    print("currentIndex before $currentIndex");
    currentIndex.value = index;
    print("currentIndex after $currentIndex");
  }

//
}
